#!/usr/bin/env python3
"""Simple test to verify console update service works."""

import sys
import os
from pathlib import Path

# Add project root to path
sys.path.insert(0, str(Path(__file__).parent))

def test_basic_import():
    """Test basic imports work."""
    try:
        print("Testing imports...")
        
        # Test version manager import
        from src.services.version_manager import VersionManager
        print("✓ VersionManager imported successfully")
        
        # Test basic version manager functionality
        vm = VersionManager()
        current_version = vm.get_current_version()
        print(f"✓ Current app version: {current_version.app}")
        
        # Test console service import
        from src.services.console_update_service import ConsoleUpdateService
        print("✓ ConsoleUpdateService imported successfully")
        
        # Test console service initialization
        service = ConsoleUpdateService()
        print("✓ ConsoleUpdateService initialized successfully")
        
        # Test basic status
        status = service.get_current_status()
        print(f"✓ Service status: {status['state']}")
        
        return True
        
    except Exception as e:
        print(f"✗ Test failed: {e}")
        import traceback
        traceback.print_exc()
        return False

def test_console_logging():
    """Test console logging functionality."""
    try:
        print("\nTesting console logging...")
        
        from src.services.console_update_service import ConsoleUpdateService
        service = ConsoleUpdateService()
        
        # Test console logging
        service._log_to_console("This is a test message")
        service._log_to_console("This is a warning", "WARNING")
        service._log_to_console("This is an error", "ERROR", {"test": "data"})
        
        print("✓ Console logging works correctly")
        return True
        
    except Exception as e:
        print(f"✗ Console logging test failed: {e}")
        return False

if __name__ == "__main__":
    print("="*50)
    print("SIMPLE CONSOLE UPDATE SERVICE TEST")
    print("="*50)
    
    success = True
    
    # Test basic imports and initialization
    if not test_basic_import():
        success = False
    
    # Test console logging
    if not test_console_logging():
        success = False
    
    print("\n" + "="*50)
    if success:
        print("🎉 ALL BASIC TESTS PASSED!")
        print("Console update service is working correctly!")
    else:
        print("❌ SOME TESTS FAILED!")
    print("="*50)